/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Aslan
 */
@Entity
@Table(name = "teaches_subject")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TeachesSubject.findAll", query = "SELECT t FROM TeachesSubject t"),
    @NamedQuery(name = "TeachesSubject.findByUserId", query = "SELECT t FROM TeachesSubject t WHERE t.teachesSubjectPK.userId = :userId"),
    @NamedQuery(name = "TeachesSubject.findBySubjectId", query = "SELECT t FROM TeachesSubject t WHERE t.teachesSubjectPK.subjectId = :subjectId")})
public class TeachesSubject implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TeachesSubjectPK teachesSubjectPK;

    public TeachesSubject() {
    }

    public TeachesSubject(TeachesSubjectPK teachesSubjectPK) {
        this.teachesSubjectPK = teachesSubjectPK;
    }

    public TeachesSubject(int userId, int subjectId) {
        this.teachesSubjectPK = new TeachesSubjectPK(userId, subjectId);
    }

    public TeachesSubjectPK getTeachesSubjectPK() {
        return teachesSubjectPK;
    }

    public void setTeachesSubjectPK(TeachesSubjectPK teachesSubjectPK) {
        this.teachesSubjectPK = teachesSubjectPK;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (teachesSubjectPK != null ? teachesSubjectPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TeachesSubject)) {
            return false;
        }
        TeachesSubject other = (TeachesSubject) object;
        if ((this.teachesSubjectPK == null && other.teachesSubjectPK != null) || (this.teachesSubjectPK != null && !this.teachesSubjectPK.equals(other.teachesSubjectPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.TeachesSubject[ teachesSubjectPK=" + teachesSubjectPK + " ]";
    }
    
}
